package jltx.fragmentpageframework.simple.fragment.shop;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import cn.jltx.support.SupportFragment;
import cn.jltx.utils.ViewHelper;
import jltx.fragmentpageframework.R;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/06/16.
 */

public class ContentFragment extends SupportFragment {
    private static final String ARG_MENU = "arg_menuNme";

    private String menuName;

    private TextView tv;
    private Button btn;
    public static ContentFragment newInstance(String menuName){
        Bundle args = new Bundle();
        args.putString(ARG_MENU,menuName);

        ContentFragment fragment = new ContentFragment();
        fragment.setArguments(args);
        return fragment;

    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle args = getArguments();
        if(args != null){
            menuName = args.getString(ARG_MENU);
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_simple_shop_content,container,false);
        initView(view);
        return view;
    }

    private void initView(View view){
        tv = ViewHelper.findViewById(view,R.id.tv_name);
        btn = ViewHelper.findViewById(view,R.id.btn);

        tv.setText("商品内容:"+menuName);
        btn.setOnClickListener(onClickListener);
    }

    private View.OnClickListener onClickListener = new View.OnClickListener(){
        @Override
        public void onClick(View v) {
            Toast.makeText(getContext(),"模拟商品详情跳转",Toast.LENGTH_SHORT).show();
        }
    };

}
